package com.itheima.ydd.common;


import com.itheima.ydd.entity.YddUser;

//前端用户对象
public class YddUserHolder {

    private static ThreadLocal<YddUser> tl = new ThreadLocal<>();


    //将用户对象，存入Threadlocal
    public static void set(YddUser user) {
        tl.set(user);
    }

    //从当前线程，获取用户对象
    public static YddUser get() {
        return tl.get();
    }

    //从当前线程，获取用户对象的id
    public static String getMobile() {
        return tl.get().getMobile();
    }

    //清空
    public static void remove() {
        tl.remove();
    }

}
